import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/pages/index/Index'
import ProjectDetail from '@/pages/project/ProjectDetail'
import ProjectList from '@/pages/project/ProjectList'
import Login from '@/pages/login/Login'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/project-list',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path: '/login',
      name: 'Login',
      component: Login
    }, {
      path: '/project-detail',
      name: '项目详情',
      component: ProjectDetail
    }, {
      path: '/',
      name: '项目列表',
      component: ProjectList,
      meta: {
        keepAlive: true // 需要缓存
      }
    }
  ],
  scrollBehavior (to, from, saveTop) {
    if (saveTop) {
      return saveTop
    } else {
      return {x: 0, y: 0}
    }
  }
})
